﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExpiredDomainSearch.Manager;

namespace ExpiredDomainSearch
{
    public partial class FormSearch : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string page = "1";
            if (Request.QueryString.AllKeys.Contains("page"))
            {
                page = Request.QueryString["page"];
            }
            else
            {
                page = "1";
            }

            if (Request.Cookies.AllKeys.Contains("csearchparam"))
            {
                SearchParam param = Common.DeSerialize(EncryptionHelper.DecryptString(Request.Cookies["csearchparam"].Value));
                SearchManager manager = new SearchManager();
                SearchResult result = manager.GetSearchedDomains(param.Keyword, param.TLD, param.Position, param.Hypen, param.Numbers, param.MaxLength, param.Deletion, page);
                gridDomains.DataSource = result.DomainList;
                gridDomains.DataBind();

                searchText.InnerText = result.TotalCount;
            }
        }
    }
}